CREATE TABLE Users (
	UserID BIGINT NOT NULL IDENTITY(1,1) PRIMARY KEY,
	Name VARCHAR(45) NOT NULL,
	Email VARCHAR(45) NOT NULL,
	Password BINARY(16) NOT NULL,
	SocialAccount VARCHAR(45)
);

CREATE TABLE Albums (
	AlbumID BIGINT NOT NULL IDENTITY(1,1) PRIMARY KEY,
	Date DATETIME,
	Name VARCHAR(45) NOT NULL,
	Description VARCHAR(50) NULL,
	OwnerID BIGINT FOREIGN KEY REFERENCES Users(UserID)
);

CREATE TABLE Pictures (
	PictureID BIGINT NOT NULL IDENTITY(1,1) PRIMARY KEY,
	Name VARCHAR(45) NULL,
	Date DATETIME,
	AlbumID BIGINT FOREIGN KEY REFERENCES Albums(AlbumID),
	Description VARCHAR(50) NULL,
	PictureFile VARBINARY(MAX) NULL
);

CREATE TABLE SharedAlbums (
	UserID BIGINT FOREIGN KEY REFERENCES Users(UserID),
	AlbumID BIGINT FOREIGN KEY REFERENCES Albums(AlbumID)
);

CREATE TABLE Comment (
	UserID BIGINT FOREIGN KEY REFERENCES Users(UserID),
	PictureID BIGINT FOREIGN KEY REFERENCES Pictures(PictureID),
	Text VARCHAR(MAX)
);

CREATE TABLE Tags (
	TagID BIGINT NOT NULL IDENTITY(1,1) PRIMARY KEY,
	Text VARCHAR(50) NOT NULL
);

CREATE TABLE TagsToPictures (
	TagID BIGINT FOREIGN KEY REFERENCES Tags(TagID),
	PictureID BIGINT FOREIGN KEY REFERENCES Pictures(PictureID)
);

CREATE TABLE PublicPictures (
	PublicID VARCHAR(MAX),
	PictureID BIGINT NOT NULL
);
